home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / misc / sss.lha / sss / cod / splt.ei < prev   
Text File  |  1994-06-20  |  2KB  |  75 lines

  1. *******************************************************************************
  2. * splt 1.1.2
  3. *******************************************************************************
  4. * INFO    program core
  5. * SYN    splt[]
  6. * MOD    d0    0=OK, else E_xxxxxx (see defs.i)
  7. * REQ    _DOSBase    dos.library pointer
  8. *******************************************************************************
  9.  
  10.     procedure splt[],d1-d7/a0-a2/a6
  11.     movea.l    _DOSBase,a6
  12.     moveq.l    #0,d7    ;chunk counter
  13.     moveq.l    #0,d5    ;no error
  14.     move.l    InFlSz,d4    ;source file size
  15.  
  16.     repeat
  17.  
  18.      StrU[d7,ExtnAdr,DgtNo]    ;build extension
  19.      prt[#txt_wrting]    ;a0 already saved
  20.      prt[#OutBs]    ;show current chunk name
  21.  
  22.       move.l    #OutBs,d1    ;open new destination file
  23.      move.l    #MODE_NEWFILE,d2
  24.      jsr    (_LVOOpen,a6)
  25.      movea.l    d0,a2    ;store filehandle
  26.  
  27.      when d0.l        ;if file opened successfully
  28.  
  29.       move.l    ChnkSz,d6    ;bytes to read
  30.       when.s d4«d6    ;if not enough bytes left
  31.        move.l    d4,d6    ;read all remaining ones
  32.       ewhen
  33.       sub.l    d6,d4    ;bytes left
  34.  
  35.       repeat
  36.  
  37.        move.l    InFlHnd,d1    ;source filehandle
  38.        move.l    WrkBufAdr,d2    ;destination buffer
  39.        when.s d6»=WrkBufLen
  40.         move.l    WrkBufLen,d3    ;fill the work buffer
  41.        othw
  42.         move.l    d6,d3    ;read only necessary data
  43.        ewhen
  44.        jsr    (_LVORead,a6)
  45.        sub.l    d0,d6    ;update bytes to write
  46.  
  47.        move.l    a2,d1    ;destination filehandle
  48.        move.l    WrkBufAdr,d2    ;buffer
  49.        move.l    d0,d3    ;write bytes read to destination
  50.        jsr    (_LVOWrite,a6)
  51.  
  52.        when.s d0<d3    ;if not all bytes written
  53.         moveq.l    #E_DSTFL,d5    ;give error
  54.        ewhen        ;('<' cos d0 could be -1)
  55.  
  56.       until ~d6.l | d5    ;exit if buffer completely written
  57.             ;or error on writing
  58.  
  59.      othw
  60.       moveq.l    #E_DSTFL,d5    ;error opening destination!
  61.       exit        ;exit repeat...until
  62.      ewhen
  63.  
  64.      move.l    a2,d1    ;close destination file
  65.      jsr    (_LVOClose,a6)
  66.  
  67.      move.l    ChkBrk[],d5    ;check if CTRL-C
  68.      addq.l    #1,d7    ;next chunk
  69.     until {d7.l»MaxChnk} | d5    ;exit if chunks over
  70.             ;or error
  71.  
  72.     prt[#txt_ENTER]
  73.     move.l    d5,d0    ;ErrCode
  74.     eproc
  75.